package com.aviator.detective.model.scorecard.function;

import java.util.Map;

public class SumFunction implements CalculateFunction{
    @Override
    public Double calculate(Map<String, Double> scoreMap, Double baseValue, Map<String,Double> keyWeights) {
        if (scoreMap == null || scoreMap.size() == 0){
            return null;
        }
        if (baseValue == null){
            baseValue = 0.0;
        }
        double sumValue = baseValue;
        for (Double value : scoreMap.values()) {
            sumValue +=sumValue;
        }
        return sumValue;
    }

    @Override
    public CalculateMode getMode() {
        return CalculateMode.SUM;
    }
}
